#include <stdio.h>
#include <math.h>
#include <string.h>

#define BUFSIZE 80
char buf1[BUFSIZE],buf2[BUFSIZE];

float floatValue;
unsigned int uintValue;
unsigned int multiplier;

#define printFloat(x,m) { floatValue = x; multiplier = m; _printFloat(); }

void _printFloat() {
    char *ptr = buf2;
    if(floatValue < 0) {
        uintValue = -floatValue*multiplier + 0.5;
        if(uintValue) *ptr++ = '-';
    }
    else {
        uintValue = floatValue*multiplier + 0.5;
    }
    sprintf(ptr,"%d",uintValue/multiplier);
    ptr = buf2 + strlen(buf2);
    *ptr++ = '.';
    uintValue %= multiplier;
    while(multiplier > 10) {
        multiplier /= 10;
        if(uintValue >= multiplier) break;
        *ptr++ = '0';
    }
    sprintf(ptr,"%d",uintValue);
}

main() {
    unsigned int k,prec,mult;
    float x,eps = 1e-5;
    float xround;
    char fmt[80];
    for(k = 0; k < 1000000; k++) {
        x = k*eps - 5;
        for(mult=10,prec = 1; prec < 7; prec++,mult*=10) {
            sprintf(fmt,"%%.%df",prec);
            xround = (float)(round(x*mult)/mult);
            snprintf(buf1,80,fmt,xround);
            printFloat(x,mult);
            if(strcmp(buf1,buf2)) {
                printf("%s %d %.8f %s %s\n",fmt,mult,x,buf1,buf2);
            }
        }
    }
}